#include<iostream>
#include"my_binary_tree.h"
using namespace std;

int main(){
	my_binary_tree<int> bt1(1);
	my_binary_tree<int> bt2(2);
	my_binary_tree<int> bt3(3);
	bt1.append(&bt2,"left");
	bt1.append(&bt3,"right");
	cout<<"test:show_binary_tree"<<endl;
	bt1.show_binary_tree("first_root");
	cout<<endl;
	bt1.show_binary_tree("mid_root");
	cout<<endl;
	bt1.show_binary_tree("last_root");	
	cout<<endl;
	bt1.show_binary_tree("layer_first");	
	cout<<endl;
	cout<<"test:get_lrest_leave"<<endl;
	my_binary_tree<int>* p0=bt1.get_lrest_leave("left");
	p0->show_binary_tree("mid_root");
//	my_binary_tree<int>* p=bt1.get_lrest_leave("right");
//	p->show_binary_tree("mid_root");
	cout<<endl;
	cout<<"test:tranversal_binary_tree"<<endl;
	bt1.traversal_binary_tree("mid_root",print);
	cout<<endl;
	bt1.traversal_binary_tree("mid_root",self_increase);
	bt1.traversal_binary_tree("mid_root",print);
	cout<<endl;
	cout<<"test:construct_binary_tree"<<endl;
	vector<int> v;
	int height=3;
	int sum=pow(2,height)-1;
	for(int i=0;i<sum;i++){
		v.push_back(i);
	}
	my_binary_tree<int>* p=bt1.construct_full_binary_tree(v,0);
//	bt1.traversal_binary_tree("layer_first",print);
//	cout<<endl; 
	p->traversal_binary_tree("layer_first",print);
	cout<<endl;
	cout<<"test=="<<endl;
	my_binary_tree<int>* pp=bt1.construct_full_binary_tree(v,0);
	pp->traversal_binary_tree("layer_first",print);
	cout<<endl;
	if((*p)==(*pp)){
		cout<<"true"<<endl;
	}
	else{
		cout<<"false"<<endl;
	}
	cout<<"test!="<<endl;
	if((*p)!=bt1){
		cout<<"true"<<endl;
	}
	else{
		cout<<"false"<<endl;
	}
	cout<<"test:get_height"<<endl;
	cout<<(*p).get_height()<<endl;
	cout<<"test:print_full_to_vector"<<endl;
	vector<int> vv;
    p->print_full_to_vector(vv); 
    for_each(vv.begin(),vv.end(),print);
	cout<<endl;
	cout<<"test:<<"<<endl;
	cout<<(*p)<<endl;
	
	return 0;
}
    
